package com.utils.module;

import android.app.Activity;
import android.content.Context;
import android.util.DisplayMetrics;
import android.view.WindowManager;

/**
 * Created by Administrator on 2016/5/13.
 */
public class ScreenUtils {

    public static int getScreenWidth(Context context){
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        int width = wm.getDefaultDisplay().getWidth();
        return width ;
    }

    public static int getScreenHeight(Context context){
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        int height = wm.getDefaultDisplay().getHeight();
        return height ;
    }

    public static int getScreenWidthLogic(Activity context){
        DisplayMetrics metric = new DisplayMetrics();
        context.getWindowManager().getDefaultDisplay().getMetrics(metric);
//        metric.widthPixels;     // 屏幕宽度（像素）
        return (int)(metric.widthPixels/metric.density);
    }

    public static int getScreenHeightLogic(Activity context){
        DisplayMetrics metric = new DisplayMetrics();
        context.getWindowManager().getDefaultDisplay().getMetrics(metric);
//        metric.widthPixels;     // 屏幕宽度（像素）
        return (int)(metric.heightPixels/metric.density);
    }

}
